//
//  DetailStrategyViewController.m
//  FlyGift
//
//  Created by lanou3g on 15/7/16.
//  Copyright (c) 2015年 lanou3g. All rights reserved.
//

#import "DetailStrategyViewController.h"
#import "ControlView.h"
#import "UMSocial.h"
@interface DetailStrategyViewController ()<UMSocialUIDelegate>

@property(nonatomic,strong)UIScrollView * scrollView;
@property(nonatomic,strong)UIImageView * topView;
@property(nonatomic,strong)UIWebView * webView;

@property(nonatomic,strong)ControlView * controView;

@end

@implementation DetailStrategyViewController

-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    self.tabBarController.tabBar.hidden = YES;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationController.navigationBar.translucent = NO;
    self.navigationItem.title = @"攻略详情";
    
    self.scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight)];
    [self.view addSubview:_scrollView];
    [self addWebView];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"btnShareRotator@2x"] style:UIBarButtonItemStylePlain target:self action:@selector(rightButtonAction:)];
}

#pragma mark --- webView
-(void)addWebView
{
    self.webView = [[UIWebView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight - kP6Height(64))];
    [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:self.content_url]]];
    self.webView.scalesPageToFit = YES;
    [self.scrollView addSubview:self.webView];
}

#pragma mark --- 第三方分享
-(void)rightButtonAction:(UIBarButtonItem *)barButton
{
     [UMSocialSnsService presentSnsIconSheetView:self
                                          appKey:@"559bddb567e58e792500284c"
                                       shareText:@"你要分享的文字"
                                      shareImage:nil
                                 shareToSnsNames:@[UMShareToQzone,UMShareToSms,UMShareToSina, UMShareToTencent, UMShareToRenren, UMShareToEmail, UMShareToFacebook, UMShareToTwitter]
                                        delegate:self];
    
}


#pragma mark --- 实现下拉放大 --- 功能未完全实现,暂时不要
/*
-(void)addTopView
{
    self.scrollView.contentInset = UIEdgeInsetsMake(kP6Height(a) * 0.5, 0, 0, 0);
    self.topView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"gfztqa8o6.jpg"]];
    self.topView.frame = CGRectMake(0, - kP6Height(a), kScreenWidth, kP6Height(a));
    self.topView.contentMode = UIViewContentModeScaleAspectFill;//等比例缩放
    [self.scrollView addSubview:_topView];
}
-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    CGFloat down = - (a * 0.5) - scrollView.contentOffset.y;
    if (down < 0) {
        return;
    }
    CGRect frame = self.topView.frame;
    frame.size.height = a + down;
    self.topView.frame = frame;
}
*/

- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    self.tabBarController.tabBar.hidden = NO;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}


@end
